/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package GSN1.provider;

import GSN1.util.GSN1AdapterFactory;

import java.util.ArrayList;
import java.util.Collection;

import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;

import org.eclipse.emf.edit.provider.ChangeNotifier;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IChangeNotifier;
import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;

/**
 * This is the factory that is used to provide the interfaces needed to support Viewers.
 * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
 * The adapters also support Eclipse property sheets.
 * Note that most of the adapters are shared among multiple instances.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public class GSN1ItemProviderAdapterFactory extends GSN1AdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable {
	/**
	 * This keeps track of the root adapter factory that delegates to this adapter factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ComposedAdapterFactory parentAdapterFactory;

	/**
	 * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected IChangeNotifier changeNotifier = new ChangeNotifier();

	/**
	 * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Collection<Object> supportedTypes = new ArrayList<Object>();

	/**
	 * This constructs an instance.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public GSN1ItemProviderAdapterFactory() {
		supportedTypes.add(IEditingDomainItemProvider.class);
		supportedTypes.add(IStructuredItemContentProvider.class);
		supportedTypes.add(ITreeItemContentProvider.class);
		supportedTypes.add(IItemLabelProvider.class);
		supportedTypes.add(IItemPropertySource.class);
	}

	/**
	 * This keeps track of the one adapter used for all {@link GSN1.Case} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CaseItemProvider caseItemProvider;

	/**
	 * This creates an adapter for a {@link GSN1.Case}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createCaseAdapter() {
		if (caseItemProvider == null) {
			caseItemProvider = new CaseItemProvider(this);
		}

		return caseItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link GSN1.SolvedByModular} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SolvedByModularItemProvider solvedByModularItemProvider;

	/**
	 * This creates an adapter for a {@link GSN1.SolvedByModular}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createSolvedByModularAdapter() {
		if (solvedByModularItemProvider == null) {
			solvedByModularItemProvider = new SolvedByModularItemProvider(this);
		}

		return solvedByModularItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link GSN1.InContextOfModular} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected InContextOfModularItemProvider inContextOfModularItemProvider;

	/**
	 * This creates an adapter for a {@link GSN1.InContextOfModular}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createInContextOfModularAdapter() {
		if (inContextOfModularItemProvider == null) {
			inContextOfModularItemProvider = new InContextOfModularItemProvider(this);
		}

		return inContextOfModularItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link GSN1.SolvedBy} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SolvedByItemProvider solvedByItemProvider;

	/**
	 * This creates an adapter for a {@link GSN1.SolvedBy}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createSolvedByAdapter() {
		if (solvedByItemProvider == null) {
			solvedByItemProvider = new SolvedByItemProvider(this);
		}

		return solvedByItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link GSN1.InContextOf} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected InContextOfItemProvider inContextOfItemProvider;

	/**
	 * This creates an adapter for a {@link GSN1.InContextOf}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createInContextOfAdapter() {
		if (inContextOfItemProvider == null) {
			inContextOfItemProvider = new InContextOfItemProvider(this);
		}

		return inContextOfItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link GSN1.Goal} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected GoalItemProvider goalItemProvider;

	/**
	 * This creates an adapter for a {@link GSN1.Goal}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createGoalAdapter() {
		if (goalItemProvider == null) {
			goalItemProvider = new GoalItemProvider(this);
		}

		return goalItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link GSN1.Strategy} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected StrategyItemProvider strategyItemProvider;

	/**
	 * This creates an adapter for a {@link GSN1.Strategy}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createStrategyAdapter() {
		if (strategyItemProvider == null) {
			strategyItemProvider = new StrategyItemProvider(this);
		}

		return strategyItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link GSN1.Solution} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SolutionItemProvider solutionItemProvider;

	/**
	 * This creates an adapter for a {@link GSN1.Solution}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createSolutionAdapter() {
		if (solutionItemProvider == null) {
			solutionItemProvider = new SolutionItemProvider(this);
		}

		return solutionItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link GSN1.Context} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ContextItemProvider contextItemProvider;

	/**
	 * This creates an adapter for a {@link GSN1.Context}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createContextAdapter() {
		if (contextItemProvider == null) {
			contextItemProvider = new ContextItemProvider(this);
		}

		return contextItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link GSN1.Justification} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected JustificationItemProvider justificationItemProvider;

	/**
	 * This creates an adapter for a {@link GSN1.Justification}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createJustificationAdapter() {
		if (justificationItemProvider == null) {
			justificationItemProvider = new JustificationItemProvider(this);
		}

		return justificationItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link GSN1.Assumption} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AssumptionItemProvider assumptionItemProvider;

	/**
	 * This creates an adapter for a {@link GSN1.Assumption}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createAssumptionAdapter() {
		if (assumptionItemProvider == null) {
			assumptionItemProvider = new AssumptionItemProvider(this);
		}

		return assumptionItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link GSN1.AwayContext} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AwayContextItemProvider awayContextItemProvider;

	/**
	 * This creates an adapter for a {@link GSN1.AwayContext}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createAwayContextAdapter() {
		if (awayContextItemProvider == null) {
			awayContextItemProvider = new AwayContextItemProvider(this);
		}

		return awayContextItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link GSN1.AwaySolution} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AwaySolutionItemProvider awaySolutionItemProvider;

	/**
	 * This creates an adapter for a {@link GSN1.AwaySolution}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createAwaySolutionAdapter() {
		if (awaySolutionItemProvider == null) {
			awaySolutionItemProvider = new AwaySolutionItemProvider(this);
		}

		return awaySolutionItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link GSN1.AwayGoal} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AwayGoalItemProvider awayGoalItemProvider;

	/**
	 * This creates an adapter for a {@link GSN1.AwayGoal}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createAwayGoalAdapter() {
		if (awayGoalItemProvider == null) {
			awayGoalItemProvider = new AwayGoalItemProvider(this);
		}

		return awayGoalItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link GSN1.ArgumentModule} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ArgumentModuleItemProvider argumentModuleItemProvider;

	/**
	 * This creates an adapter for a {@link GSN1.ArgumentModule}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createArgumentModuleAdapter() {
		if (argumentModuleItemProvider == null) {
			argumentModuleItemProvider = new ArgumentModuleItemProvider(this);
		}

		return argumentModuleItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link GSN1.ContractModule} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ContractModuleItemProvider contractModuleItemProvider;

	/**
	 * This creates an adapter for a {@link GSN1.ContractModule}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createContractModuleAdapter() {
		if (contractModuleItemProvider == null) {
			contractModuleItemProvider = new ContractModuleItemProvider(this);
		}

		return contractModuleItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link GSN1.TaggedValue} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected TaggedValueItemProvider taggedValueItemProvider;

	/**
	 * This creates an adapter for a {@link GSN1.TaggedValue}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createTaggedValueAdapter() {
		if (taggedValueItemProvider == null) {
			taggedValueItemProvider = new TaggedValueItemProvider(this);
		}

		return taggedValueItemProvider;
	}

	/**
	 * This returns the root adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ComposeableAdapterFactory getRootAdapterFactory() {
		return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
	}

	/**
	 * This sets the composed adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
		this.parentAdapterFactory = parentAdapterFactory;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean isFactoryForType(Object type) {
		return supportedTypes.contains(type) || super.isFactoryForType(type);
	}

	/**
	 * This implementation substitutes the factory itself as the key for the adapter.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter adapt(Notifier notifier, Object type) {
		return super.adapt(notifier, this);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object adapt(Object object, Object type) {
		if (isFactoryForType(type)) {
			Object adapter = super.adapt(object, type);
			if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) {
				return adapter;
			}
		}

		return null;
	}

	/**
	 * This adds a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void addListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.addListener(notifyChangedListener);
	}

	/**
	 * This removes a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void removeListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.removeListener(notifyChangedListener);
	}

	/**
	 * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void fireNotifyChanged(Notification notification) {
		changeNotifier.fireNotifyChanged(notification);

		if (parentAdapterFactory != null) {
			parentAdapterFactory.fireNotifyChanged(notification);
		}
	}

	/**
	 * This disposes all of the item providers created by this factory. 
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void dispose() {
		if (caseItemProvider != null) caseItemProvider.dispose();
		if (solvedByModularItemProvider != null) solvedByModularItemProvider.dispose();
		if (inContextOfModularItemProvider != null) inContextOfModularItemProvider.dispose();
		if (solvedByItemProvider != null) solvedByItemProvider.dispose();
		if (inContextOfItemProvider != null) inContextOfItemProvider.dispose();
		if (goalItemProvider != null) goalItemProvider.dispose();
		if (strategyItemProvider != null) strategyItemProvider.dispose();
		if (solutionItemProvider != null) solutionItemProvider.dispose();
		if (contextItemProvider != null) contextItemProvider.dispose();
		if (justificationItemProvider != null) justificationItemProvider.dispose();
		if (assumptionItemProvider != null) assumptionItemProvider.dispose();
		if (awayContextItemProvider != null) awayContextItemProvider.dispose();
		if (awaySolutionItemProvider != null) awaySolutionItemProvider.dispose();
		if (awayGoalItemProvider != null) awayGoalItemProvider.dispose();
		if (argumentModuleItemProvider != null) argumentModuleItemProvider.dispose();
		if (contractModuleItemProvider != null) contractModuleItemProvider.dispose();
		if (taggedValueItemProvider != null) taggedValueItemProvider.dispose();
	}

}
